package com.example.forum.controller;

import com.example.forum.common.AppResult;
import com.example.forum.exception.ApplicationException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

//  api 描述信息
@Api(tags = "TestController 测试接口")

@RestController
@RequestMapping("/test")
public class Test {
    @ApiOperation(value = "测试1、异常接口")
    @GetMapping("/appexception")
    public AppResult appException() {
        throw new ApplicationException("appException");
    }

    @ApiOperation(value = "测试2、异常接口")
    @GetMapping("/exception")
    public AppResult Exception() {
        throw new ApplicationException("Exception");
    }

    @ApiOperation(value = "测试3、hello + 参数")
    @GetMapping("/hello")
    public AppResult hello(@RequestParam("name") String name) {
        return AppResult.success("hello" + name);
    }

}
